// pages/location/poidetail/poidetail.js
const app = getApp()
const http = require("../../../utils/http.js")

Page({

  /**
   * 页面的初始数据
   */
  data: {
    StatusBar: app.globalData.StatusBar,
    CustomBar: app.globalData.CustomBar,
    WindowHeight: app.globalData.WindowHeight,
    ScreenHeight: app.globalData.ScreenHeight,

    poiId: '',
    poi: {}
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      poiId: options.poiId
    })
    this.initData()
  },

  initData(){
    let that = this
    http.get("/poi/getDetail", {
      poiId: that.data.poiId
    }).then(res=>{
      that.setData({
        poi: res.data.data
      })
    })
  },
  toLocation(e){
    let name = e.currentTarget.dataset.name
    let latitude = e.currentTarget.dataset.lat
    let longitude = e.currentTarget.dataset.lng
    wx.navigateTo({
      url: '/pages/location/index?name=' + name + '&latitude=' + latitude + '&longitude=' + longitude,
    })
  }
})